package com.richapp.launcher.database.system.dao;

import android.content.Context;
import android.util.Log;

import com.j256.ormlite.stmt.DeleteBuilder;
import com.richapp.launcher.database.system.SystemBaseDao;
import com.richapp.launcher.database.system.mode.SceneActionModel;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by dean on 2017/10/9 0009.
 */

public class SceneActionDao extends SystemBaseDao<SceneActionModel> {

    public SceneActionDao(Context context) {
        super(context,SceneActionModel.class);
    }

    public List<SceneActionModel> getList(String sceneName){
        List<SceneActionModel> list = new ArrayList<SceneActionModel>();
        try {
            list = gettOp().queryBuilder().orderBy("orderNumber",true).where().eq("sceneName", sceneName).query();
        } catch (Exception e) {
            Log.e(getClass().getName(), e.getMessage());
        }
        return list;
    }

    public void del(String sceneName){
        try {
            DeleteBuilder<SceneActionModel, Integer> deleteBuilder = gettOp().deleteBuilder();
            deleteBuilder.where().eq("sceneName", sceneName);
            deleteBuilder.delete();
        } catch (Exception e) {
            Log.e(getClass().getName(), e.getMessage());
        }
    }
}
